package com.study.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.study.bean.Cat;
import com.study.bean.Mouse;
import com.study.bean.MyImportSelector;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Import;

/**
 * @desc:
 * @author: panxiyi
 * @date: 2023/5/20 3:20 下午
 */

//@Import(MyImportSelector.class)
//@Import(Mouse.class)
@ComponentScan(value = {"com.study.bean"})
public class SpringConfig {

    //@Bean
    //@ConditionalOnClass(Mouse.class)
    //@ConditionalOnClass(name = "com.study.bean.Mouse")
 //   @ConditionalOnMissingClass("com.study.bean.Mouse")
//    @ConditionalOnBean(name = "jerry")
//    @ConditionalOnMissingClass("com.study.bean.Dog")
//    public Cat tom() {
//        return new Cat();
//    }

    @Bean
    @ConditionalOnClass(name = "com.mysql.jdbc.Driver")
    public DruidDataSource dataSource() {
        return new DruidDataSource();
    }

}
